package controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import pojo.Comment;
import pojo.Merchant;
import pojo.Order;
import service.MerchantManager;

@Controller
public class MerchantController {
	@Resource(name="merchantManager")
	private MerchantManager merchantManager;
	
	@RequestMapping(value = "/getMerchants", method=RequestMethod.GET)
	@ResponseBody
	public List<Merchant>showMerchants(String typeId){
		List<Merchant> merchantList = merchantManager.findByType(typeId);
		return merchantList;
	}
	
	@ResponseBody
	@RequestMapping(value = "/showComments", method=RequestMethod.GET)
	public List<Comment>showComments(String id){
		return merchantManager.loadCommentByMerchantId(id);
	}
	
	@ResponseBody
	@RequestMapping(value = "/showStar", method=RequestMethod.GET)
	public List<Integer>showStar(String id){
		List<Integer> integers = merchantManager.loadCommentStar(id);
		for(Integer integer :integers){
			System.out.println(integer+" kkdkkddkkd");
		}
		return merchantManager.loadCommentStar(id);
	}
	
	@ResponseBody
	@RequestMapping(value="/getOrderByMerchantId",method=RequestMethod.GET)
	public List<Order> getOrderByMerchantId(String id){
		List<Order> list = merchantManager.getOrderByMerchantId(id);
		System.out.println(list);
		return list;
	}
}
